layui.use(['layer', 'form', 'table', 'admin', 'ax'], function () {
    var $ = layui.$;
    var layer = layui.layer;
    var form = layui.form;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;

    $.ajax({
		type:"post",
		url: Feng.ctxPath + "/wx_order/getDetail",
		data:{ },
		datatype:"json",
		success:function(result){
			var code = result.code;
			if(code == '200'){
				var datas = result.data;
				if(datas != null && datas != ""){
					$("#todayAmount").text("￥" + datas.sumAmount);
				}else{
					$("#todayAmount").text("0");
				}
			}else{
				alert(result.msg);
			}
		},
		error:function(){
			alert("error");
		}
	});
    
    $.ajax({
    	type:"post",
    	url: Feng.ctxPath + "/wx_order/getYesDetail",
    	data:{ },
    	datatype:"json",
    	success:function(result){
    		var code = result.code;
    		if(code == '200'){
    			var datas = result.data;
    			if(datas != null && datas != ""){
    				$("#yesAmount").text("￥" + datas.sumAmount);
    			}else{
    				$("#yesAmount").text("0");
    			}
    		}else{
    			alert(result.msg);
    		}
    	},
    	error:function(){
    		alert("error");
    	}
    });
    var seriesDatas = [];
    var xAxisDatas = [];
  //初始化ehcharts实例
    var myChart=echarts.init(document.getElementById("box"));
    //指定图表的配置项和数据
    var option={
        //标题
        title:{
          text:'7日收益表'
        },
        //工具箱
        //保存图片
        toolbox:{
            show:true,
            feature:{
                saveAsImage:{
                    show:true
                }
            }
        },
        //图例-每一条数据的名字叫销量
        legend:{
            data:['每日流水']
        },
        //x轴
        xAxis:{
            data:xAxisDatas
        },
        //y轴没有显式设置，根据值自动生成y轴
        yAxis:{},
        //数据-data是最终要显示的数据
        series:[{
            name:'每日流水',
            type:'line',
            data:seriesDatas
        }]
    };
    $.ajax({
    	type:"post",
    	url: Feng.ctxPath + "/wx_order/getWeekDetail",
    	data:{ },
    	datatype:"json",
    	success:function(result){
    		var code = result.code;
    		if(code == '200'){
    			var datas = result.data;
    			if(datas != null && datas != ""){
    				console.log(datas);
    				for(var i=0;i < datas.length;i++){
    					xAxisDatas[i] = datas[i].weekTime;
    					seriesDatas[i]= datas[i].amount;
    				}
    				console.log(xAxisDatas);
    				console.log(seriesDatas);
    				 //使用刚刚指定的配置项和数据项显示图表
    			    myChart.setOption(option);
    			}else{
    				$("#yesAmount").text("0");
    			}
    		}else{
    			alert(result.msg);
    		}
    	},
    	error:function(){
    		alert("error");
    	}
    });
    
    
});
